//package com.example.demo.service.impl;
//
//import com.alibaba.fastjson.JSON;
//import com.example.demo.module.mq.UserDto;
//import com.example.demo.service.PushService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.jms.core.JmsMessagingTemplate;
//import org.springframework.jms.core.MessageCreator;
//import org.springframework.stereotype.Service;
//
//import javax.jms.Destination;
//import javax.jms.JMSException;
//import javax.jms.Message;
//import javax.jms.Session;
//
///**
// * @Author:lgl
// * @Description:
// * @Date:Create in 2017/11/30 .
// */
//@Service("pushService")
//public class PushUserServiceImpl implements PushService {
//
//    @Autowired // 也可以注入JmsTemplate，JmsMessagingTemplate对JmsTemplate进行了封装
//    private JmsMessagingTemplate jmsTemplate;
//
//    @Autowired
//    @Qualifier("userServiceQueue")
//    private Destination destination;
//
//    @Override
//    public void push(final Object info) {
//        pushExecutor.execute(new Runnable() {
//            @Override
//            public void run() {
//                jmsTemplate.send(destination, new MessageCreator() {
//                    public Message createMessage(Session session) throws JMSException {
//                        UserDto p = (UserDto) info;
//                        return session.createTextMessage(JSON.toJSONString(p));
//                    }
//                });
//            }
//        });
//
//    }
//
//    public void sendMessage(Destination destination, final String message){
//        jmsTemplate.convertAndSend(destination, message);
//    }
//}
